import { configureStore } from '@reduxjs/toolkit'
import { combineReducers } from 'redux'

import afengSlice from './store'
import { persistReducer, persistStore } from 'redux-persist'
import storage from 'redux-persist/es/storage'

// 缓存数据配置
const persistConfig = {
  key: 'afeng', // LocalStorage中显示为persist:root: {};
  storage,
  blacklist: ['fuseIm'] // 写在这块的数据不会存在storage
}

const reducers = combineReducers({
  afengSlice,
})

const persistedReducer = persistReducer(persistConfig, reducers)

const store = configureStore({
  reducer: persistedReducer,
  middleware: getDefaultMiddleware =>
    getDefaultMiddleware({
      serializableCheck: false,
    }),
})

export const persist = persistStore(store);

export default store